package com.cx.mall.user.controller;

import com.cx.mall.common.entity.user.entity.UserReceiveAddress;
import com.cx.mall.common.entity.user.model.UserReceiveAddressDTO;
import com.cx.mall.common.util.ResponseVo;
import com.cx.mall.user.service.IUserReceiveAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 用户收货地址表 前端控制器
 * </p>
 *
 * @author zs
 * @since 2025-08-07
 */
@RestController
@RequestMapping("/user/address")
public class UserReceiveAddressController {

    @Autowired
    private IUserReceiveAddressService userReceiveAddressService;


    @GetMapping("/{userId}")
    public ResponseVo<List<UserReceiveAddressDTO>> get(@PathVariable("userId") Long userId){
      List<UserReceiveAddressDTO> userReceiveAddressList = userReceiveAddressService.getListByUserId(userId);
      return ResponseVo.success(userReceiveAddressList);
    }

    @PostMapping("/save")
    public ResponseVo save(@RequestBody UserReceiveAddress userReceiveAddress) {
        userReceiveAddressService.save(userReceiveAddress);
        return ResponseVo.success();
    }

}
